package cn.valo.org.controller;

import cn.valo.org.domain.ShopVo;
import cn.valo.org.service.IShopService;
import cn.valo.org.service.impl.ShopServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/shop")
public class ShopVoController {
    @Autowired
    private IShopService shopService;
    @GetMapping("/echarts")
    public List<Integer> echartsData(){
        List<ShopVo> shopVos=shopService.countByState();
        //把其中的数据转换为list或者数组  前端用于图表的y轴数据
        List<Integer> counts = shopVos.stream().map(ShopVo::getCountNum).collect(Collectors.toList());
        return counts;
    }
}
